fix(airplay): stop refusing receivers by model string, and widen the auth retry - #44
Open
snadahalli wants to merge 1 commit into
Open
Conversation
…auth retry Two checks were rejecting receivers on guesses rather than on what the receiver said. **The model-string refusal.** `AppleTV2,*`/`AppleTV3,*` were refused up front as FairPlay-only. The string is self-reported, and third-party receivers reuse it for client compatibility. A Vivitek NovoConnect on the test network advertises `AppleTV3,1` over mDNS, reports `AppleTV3,2` from GET /info, and is neither: `rmodel=AirReceiver3,1`, no HomeKit pairing, `pw=0`, and a `/fp-setup` that answers 200 to an empty body. Refusing it on sight meant never learning what it actually does. Probed directly, it authenticates fine over HTTP Digest with the on-screen PIN, then answers `501 Not Implemented` to `POST /stream` with any body — it serves `/play` and `/playback-info` but implements no screen mirroring, while its feature bits claim `mirroring: true`. Useful, specific, and completely invisible behind a model-string check. Genuine Apple TV 2/3 still cannot work. They will now say so themselves, which is accurate and debuggable rather than assumed. The check becomes a warning. **The auth retry missed the statuses receivers actually send.** The fallback into pairing triggered on `501` or `403` only. A Mac with AirPlay Receiver set to Everyone and no password answers **404** — the legacy AirPlay 1 endpoint does not exist there — and one with a password answers **470**. Receivers behind HTTP Digest answer **401**. None matched, so casting gave up without attempting to pair at all, which is why `pair_probe` could reach M4 while the app could not get near it. Matching on message text stays crude: the status is not carried through `AirPlayError::Negotiation`, so a body echoing "403" would trip it. Widening the net is still strictly better than skipping pairing silently. Threading a real status code through that error is worth doing on its own.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #43 — merge #43 first, then this. (See the note at the bottom; #42 was lost to exactly this hazard.)
Two checks were rejecting receivers on guesses rather than on what the receiver actually said.
1. The model-string refusal
AppleTV2,*/AppleTV3,*were refused up front as FairPlay-only. But the model string is self-reported, and third-party receivers reuse it for client compatibility.A Vivitek NovoConnect on the test network:
It is not an Apple TV. Refusing it on sight meant never learning what it does. Probed directly it turns out to:
WWW-Authenticate: Digest realm="airplay") with the on-screen PIN/playand/playback-info(200 OK once authenticated)501 Not ImplementedtoPOST /streamwith any body — original keys,type=110,streamType=110, or emptySo it implements AirPlay video playback but no screen mirroring at all — while its feature bits advertise
mirroring: true. That is specific, useful, and was completely invisible behind a model-string check.Genuine Apple TV 2/3 still cannot work. They will now say so themselves, which is accurate rather than assumed. The check becomes a
warn!.2. The auth retry missed the statuses receivers actually send
The fallback into pairing triggered on
501or403only. Observed in practice:/streamendpoint)None matched, so casting gave up without attempting to pair at all. That is why
pair_probecould reach M4 while the app could not get near it — the probe calls pair-setup directly and skips this gate entirely.Now retries on
401,403,404,470,501, with 3 unit tests covering the newly-handled statuses, the original two, and unrelated failures that must not retry.Known weakness, stated rather than hidden
Matching on message text is crude — a body echoing "403" would trip it. The status code is not carried through
AirPlayError::Negotiation, so there is nothing better to match on today. Widening the net is still strictly better than silently skipping pairing. Threading a real status through that error type is worth doing on its own.Verification
fmt --checkclean,clippy --all-targets --all-features -D warningsclean,cargo test --all236 passed / 0 failed, plus the hardware probes above.Merge order
This is stacked on #43. Merge #43 into master first, then merge this. Merging this into its base branch after #43 has already been merged would strand it exactly as #42 was stranded — see #43's description for what that looked like.